import {useSelector} from "react-redux";
import {Link, Form} from "react-router-dom";

export default function Buttoninfo({username,following} ) {
    // 登录用户信息
    const currentUser = useSelector(state => state.user);
    // console.log(currentUser)
    const isCurrentUser = username &&  currentUser && currentUser.username == username;
    // 自己查看
    if (isCurrentUser) {
        return (<Link to="/setting" className="btn btn-sm btn-outline-secondary action-btn">
            <i className="fa fa-cog"></i>{" "}编辑设置
        </Link>)
    }
//     别人查看
    if (following) {
        return (
            <Form method="delete"  >
                <button className="btn btn-sm action-btn btn-secondary">
                    <i className="fa fa-user-plus"></i>{" "}取消关注
                </button>
            </Form>
        )
    } else {
        return (
            <Form method="post"  >
                <button className="btn btn-sm action-btn btn-secondary">
                    <i className="fa fa-user-plus"></i>{" "}添加关注
                </button>
            </Form>
        )
    }
}